// class Solution {
// public:
//     int coinChange(vector<int>& coins, int amount) {
//     int m=coins.size();
//     vector<int>dp(amount+1,INT_MAX-1);
//     dp[0]=0;
//     for(int i=0;i<m;i++)
//        {for(int j=coins[i];j<=amount;j++)
//            {
//              dp[j]=min(dp[j],dp[j-coins[i]]+1);

//            }
//         }
    
//          if(dp[amount]==INT_MAX-1)return -1;
//          else return dp[amount];

//     }
// };class Solution {
// public:
//     int subarraySum(vector<int>& nums, int k) {
//     unordered_map<int,int>st;
//     int ret=0;
//     int sum=0;
//     st[0]=1;
//     for(auto e:nums)
//     {
//       sum+=e;
//       if(st.count(sum-k))ret+=st[sum-k];
//       st[sum]++;

//     }

//     return ret;

//     }
// };
#include<iostream>
using namespace std;
struct ListNode
{


int val;
ListNode*next;



};
  ListNode* reverseKGroup(ListNode* head, int k) {
    ListNode*cur=head;
    int cnt=0;
    while(cur)
    {
     cnt++;
     cur=cur->next;

    }
    cnt/=k;
     ListNode*newhead=new  ListNode(-1);
     newhead->next=nullptr;
    ListNode*prev=head;
    cur=head;
     ListNode*tail=newhead;
    while(cnt--)
    {
       ListNode*next;
       prev=cur;
     while(k--)
     { 
       next=cur->next;
       cur->next=tail->next;
       tail->next=cur;
       //tail=tail->next;
       cur=next;

     }
        tail=prev;

    }
    tail->next=cur;
    return newhead->next;
    }
    int main()
    {
      
   ListNode*newhead=new ListNode(-1);
    ListNode*tail=newhead;
   for(int i=1;i<=5;i++)
   {
     ListNode*newnode=new  ListNode(i);
     tail->next=newnode;
     tail=tail->next;

   }
    tail->next=nullptr;
    ListNode*cur=newhead->next;
    while(cur)
    {
     cout<<cur->val<<" ";
     cur=cur->next;



    }




    }
    class Solution {
public:
   bool _isSymmetric(TreeNode*left,TreeNode*right) 
{ 
   if(left==nullptr&&right==nullptr)return  true;
   if(left==nullptr||right==nullptr)return false;
   if(left->val!=right->val)return false;
   return _isSymmetric(left->left,right->right)&&_isSymmetric(left->right,right->left);
    

}



    bool isSymmetric(TreeNode* root) {
        if(root==nullptr)return true;
     return _isSymmetric(root->left,root->right); 
    }
};class Solution {
public:
vector<int>result;
    void inorder(TreeNode* root)
    {
      if(root==nullptr)
      return ;
      inorder(root->left);
      result.push_back(root->val);
      inorder(root->right);

    }
    int kthSmallest(TreeNode* root, int k) {
     inorder(root);
     return result[k-1];

    }
};class Solution {
public:
    vector<int> twoSum(vector<int>& nums, int target) {
       unordered_map<int,int>st;
       for(int i=0;i<nums.size();i++)
          {
               int x=target-nums[i];
               if(st.count(x))
               {
                  
                 return {i,st[x]};
               }
               st[nums[i]]=i;

          }




    return {-1,-1};

    }
};
class Solution {
public:
    int maxArea(vector<int>& height) {
    int left=0;
    int right=height.size()-1;
    int maxp=0;
    while(left<right)
    {
      maxp=max(maxp,min(height[left],height[right])*(right-left));
      if(height[left]<height[right])
        {
           left++;

        }
      else
        {right--;}


    }

   return maxp;



    }
};